/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utilities;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

/**
 *
 * @author omar
 */
public abstract class TransiantRemoval
{

    protected int NO_OF_RV ;

    protected static void saveData(String filePath, ArrayList<Double> data, int startVlaue) throws IOException
    {
        FileWriter writer = new FileWriter(filePath + ".csv");
        int index = 0;
        while (index < data.size())
        {
            writer.append(data.get(index) + "");
            writer.append(',');
            writer.append(startVlaue + "");
            writer.append('\n');
            index ++;
            startVlaue ++;
        }
        writer.flush();
    }

    protected ArrayList<Double> readFile(String filePath) throws FileNotFoundException, IOException
    {
        ArrayList<Double> data = new ArrayList<Double>();
        BufferedReader bufRdr  = new BufferedReader(new FileReader(filePath));
        String line = null;
        //read each line of text file
        while((line = bufRdr.readLine()) != null)
        {
            data.add(Double.parseDouble(line));
        }
        //close the file
        bufRdr.close();
        NO_OF_RV = data.size();
        return data;
    }

    public static void main(String[] args) throws IOException
    {
        ArrayList<Double> data = new ArrayList<Double>();
//        for (int i = 0; i < 10; i++)
//        {
//            data.add((double)i * 13);
//        }
//        TransiantRemoval.saveData("mostafa", data, 0);
//        data = TransiantRemoval.readFile("mostafa.csv");
//        for (int i = 0; i < data.size(); i++)
//        {
//            System.out.println(data.get(i));
//        }
    }
}
